import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'login',
      component: load('home/login')
    },
    {
      path: '/login',
      name: 'login2',
      component: load('home/login')
    },
    {
      path: '/forget',
      name: 'forget',
      component: load('home/forget')
    },
    {
      path: '/main',
      name: 'main',
      component: load('home/index'),
      children: [
        {
          path: '/test',
          name: 'test',
          component: load('template/test')
        }
      ]
    }
  ]
})

function load (component) {
  // '@' is aliased to src
  return () => import(`@/components/${component}.vue`)
}
